package com.wnxy.pms.product.core.exception;

import com.wnxy.pms.common.api.Result;
import com.wnxy.pms.common.api.enums.impl.ResultCode;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
public class GlobalException {

    @ExceptionHandler(BusinessException.class)
    public Result handlerBusinessException(BusinessException e) {
        e.printStackTrace();
        return Result.fail(e.getMessage());
    }

    @ExceptionHandler(Exception.class)
    public Result handlerExceptionException(Exception e) {
        e.printStackTrace();
        return Result.fail(ResultCode.FAILED);
    }
}
